<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('已领取优惠券列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="coupon-lwFoot-form">
                <input name="couponId" th:value="${couponId}" type="hidden">
                <div class="select-list">
                    <ul>
                        <li>
                            <p style="width: 80px">使用状态： </p>
                            <select name="memberCouponStatus" th:with="type=${@dict.getType('member_coupon_status')}">
                                <option value="">全部</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li class="select-time">
                            <p style="width: 110px">领取时间： </p>
                            <input type="text" class="time-input" style="width: 150px;" data-type="datetime" placeholder="开始时间"
                                   name="params[beginTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" style="width: 150px;" data-type="datetime" placeholder="结束时间"
                                   name="params[endTime]"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var datas = [[${@dict.getType('is_enable')}]];
    var memberCouponStatusDict = [[${@dict.getType('member_coupon_status')}]];
    var couponTypeDict = [[${@dict.getType('coupon_type')}]];
    var prefix = ctx + "back/shopCoupon";

    $(function () {
        var options = {
            url: prefix + "/searchGetList",
            height: 540,
            sortName: "createTime",
            sortOrder: "desc",
            modalName: "已领取优惠券列表",
            columns: [
                {
                    field: 'title',
                    title: '优惠券标题',
                },
                {
                    field : 'reachAmount',
                    title : '使用门槛',
                    formatter: function (value, row, index) {
                        if(0 == value){
                            return "无使用门槛";
                        }else{
                            return "满"+value+"元可用";

                        }
                    }
                },
                {
                    field: 'couponType',
                    title: '优惠信息',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<span style="font-weight: bold">' + $.table.selectDictLabel(couponTypeDict, value) + '</span>');
                        if(1 == value){
                            //满减
                            actions.push('<br/><label>面值：</label><span style="font-weight: bold">' + row.faceValue + '元</span>');
                        }else{
                            //折扣
                            actions.push('<br/><label>面值：</label><span style="font-weight: bold">' + row.discountValue + '折</span>');
                        }
                        return actions.join('');
                    }
                },
                {
                    field: 'avatar',
                    title: '会员头像',
                    formatter: function (value, row, index) {
                        return $.common.sprintf("<img class='img-circle img-sm' data-height='%s' data-width='%s' data-target='%s'  style='border-radius: 0;' src='%s'/>", 500, 'auto', 'self', value);
                    }
                },
                {
                    field: 'phone',
                    title: '会员手机号',
                },
                {
                    field: 'memberCouponStatus',
                    title: '使用状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(memberCouponStatusDict, value);
                    },
                    sortable: true
                },
                {
                    field: 'createTime',
                    title: '领取时间',
                    sortable: true
                },
                {
                    field: 'receiveChannelDesc',
                    title: '获取途径',
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>